import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-07-19
 * Time: 18:02
 */
class Student {
    String name;
    int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

}

class NameComp implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o2.name.compareTo(o1.name);
    }
}
class AgeComp implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o2.age - o1.age;
    }
}

public class Test {
    public static void main(String[] args) {

    }
    public static void main2(String[] args) {
        Student student1 = new Student("zhangsan",10);
        Student student2 = new Student("lisi",20);

        //使用比较器比较 -- 大根堆
        NameComp nameComp = new NameComp();
        AgeComp  compare = new AgeComp();

        Queue<Student> priorityQueue1 = new PriorityQueue<>(nameComp);

        priorityQueue1.offer(student1);
        priorityQueue1.offer(student2);

    }
    public static void main1(String[] args) {
        Queue<Integer> priorityQueue1 = new PriorityQueue<>();
        priorityQueue1.offer(10);
        priorityQueue1.offer(2);

        //priorityQueue底层默认是小根堆
        System.out.println(priorityQueue1.poll());

    }
}
